package com.hfh.homework;

import java.io.BufferedWriter;
import java.io.ObjectInputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author hfh
 * @Date 2022 09 14 16 11
 **/
public class LoginServer {
    public static void main(String[] args) throws Exception {
        ServerSocket ss = new ServerSocket(8888);
        Socket s = ss.accept();

        ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
        User user = (User) ois.readObject();

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        if ("1111".equals(user.getUsername())&&"1111".equals(user.getPassword())){
            bw.write("登录成功");
        }else {
            bw.write("登录失败");
        }

        bw.close();
        ois.close();
        s.close();
        ss.close();

    }
}